<template>
  <div>
      <van-nav-bar
         left-arrow
        class="app-nav-bar"
        title="卫生检查列表"
        @click-left="$router.back()"
      />
      <el-form style="padding:20px 10px 0 10px;background-color:#fff" :inline="true" class="demo-form-inline">
        <el-form-item label="卫生检查日期">
            <el-date-picker
                v-model="date"
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="选择日期">
                </el-date-picker>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" size="mini" @click="getEventListAll">查询</el-button>
        </el-form-item>
         <el-form-item>
            <el-button type="success" size="mini" @click="AttenceExcList">卫生检查录入</el-button>
        </el-form-item>
        </el-form>
       <el-table :data="tableData" style="width:100%">
          <el-table-column label="序号" align="center" width="50">
              <template slot-scope="scope">
                  <span style="margin-left:10px">{{scope.row.id}}</span>
              </template>
          </el-table-column>
          <el-table-column label="卫生检查日期" align="center">
              <template slot-scope="scope">
                  <span style="margin-left:10px">{{scope.row.checkDate}}</span>
              </template>
          </el-table-column>
          <el-table-column label="宿舍" align="center">
              <template slot-scope="scope">
                  <span else-if style="margin-left:10px">{{scope.row.dorAddress}}</span>
              </template>
          </el-table-column>
          <el-table-column label="总扣分" align="center">
              <template slot-scope="scope">
                  <span style="margin-left:10px">{{scope.row.totalPdeduct}}</span>
              </template>
          </el-table-column>
          <el-table-column label="总得分" align="center">
              <template slot-scope="scope">
                  <span style="margin-left:10px">{{scope.row.totalScore}}</span>
              </template>
          </el-table-column>
          <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button size="mini" icon="el-icon-view" circle @click="ExcDetail(scope.row)"></el-button>
                <el-button size="mini" type="primary" icon="el-icon-edit" circle @click="handleEdit(scope.row)"></el-button>
                <el-button size="mini" type="danger" icon="el-icon-delete" circle @click="handleDelete(scope.row)"></el-button>
              </template>
          </el-table-column>
      </el-table>
  </div>
</template>

<script>
import {Dialog} from 'vant'
export default {
    name:'Hygiene1',
    data(){
        return{
            tableData: [],
            date:''
        }
    },
    methods:{
       async getEventListAll(){
            var {data:res} = await this.$axios({
                url:this.$location.getHygieneAll,
                params:{
                    checkDate:this.date
                }
            })
            // console.log(res.data)
            this.tableData=res.data
       },
       AttenceExcList() {
           const vm = this;
           vm.$router.push({name: 'HygieneAdd', params: { id: 10}})
        //    this.$router.push('/HygieneAdd')
       },
         ExcDetail(row){
             const vm = this;
           vm.$router.push({name: 'HygieneDetail', params: { id: row.id}})
        //    this.$router.push('/HygieneDetail/'+row.id)
       },
       handleEdit(row){
           const vm = this;
           vm.$router.push({name: 'HygieneEdit', params: { id: row.id}})
        //    this.$router.push('/HygieneEdit/'+row.id)
       },
       handleDelete(row){
        //    deleteExc
        Dialog.confirm({
            title: '提示',
            message: '确认删除？',
            })
            .then(async () => {
                var {data:res} = await this.$axios({
                    url:this.$location.deleteHygieneById,
                    params:{
                        id:row.id
                    }
                })
                if(res.status==200){
                    this.$toast.success(res.msg)
                    this.getEventListAll();
                }else{
                    this.$toast.fail(res.msg)
                    this.getEventListAll();
                }
            })
            .catch(() => {
                // on cancel
            });
       },
        add() {
           this.$router.push('/ExcAdd')
       },
    },
    created(){
        this.getEventListAll()
    }
}
</script>

<style lang="less" scoped>
    /deep/ .app-nav-bar{
        background-color:#35d299;
        .van-nav-bar__title{
            color: #fff;
        }
        .van-icon{
            color: #fff;
        }
    }
</style>